package com.bua.net;

import com.bua.toothfactory.config.Setup;

import android.content.Context;

import java.util.HashMap;

/**
 * 配置文件----网络通信、协议 包括静态变量、方法等
 *
 * @author leizhang
 *
 */

/**
 * @author shenran
 */
public class NetConfig {

    /**
     * 服务器的域名
     */
    public static final String ServerDomain = Setup.isDemo ? Setup
            .getAppCachePath() : "http://toothapi.sinaapp.com/index.php/";// 外网测试环境
    // public static final String ServerDomain = "http://api.ubox.cn/";
    // //外网生产环境环境

    public static Context CONTEXT;
    public static final String RESPONSE_OK = "200";
    public static final String FORGET_PSW_CODE = "5006";// 已发送验证码状态
    public static final int CONNECTION_TIMEOUT = 10 * 1000;
    public static final int READ_TIMEOUT = 30 * 1000;
    public static String DeviceID = "";
    public static String DepartmentID = "";

    /**
     * 各个协议段的请求ID
     *
     * @author leizhang
     */
    public static enum HttpRequestId {
        NOT_EXIST, // 不存在
        ON_WORK, // 备用
        GET_DENTIST_LIST, // 获取医生列表
        GET_ORDER_LIST, // 获取订单列表
        CREATE_ORDER, // 创建订单
        GET_ORDER_DETAIL, // 获取订单详情
        CREATE_DESIGN_ORDER, // 创建设计图
        GET_DESIGN_ORDER_DETAIL, // 获取设计订单详情
        REGISTER_EQUIPMENT, //注册科室
        GET_DEPARTMENT,//获取科室
        GET_JGSLIST//获取技工所列表

    }

    ;

    /**
     * 协议段，和请求ID对应
     */
    public static String[] net_interface = {"-1", // 不存在
            "", // 保留
            "user/DentistList", // 获取医生列表
            "order/GetOrdersList", // 获取订单列表
            "order/CreateOrder", // 创建订单
            "order/GetOrderDetail", // 获取订单详情
            "order/CreateDesignOrder", // 创建设计图
            "design/GetDesign",// 获取设计订单详情
            "equipment/Register",  //注册科室
            "equipment/GetDepartmentByMac",//获取科室
            "order/GetJGSList"//获取技工所列表

    };

    /**
     * 协议格式
     */
//	public static final String protocol_form = "";
    public static final String pro_version = "version";
    public static final String dev_id = "DeviceID";
    public static final String dep_id = "DepartmentID";
    public static final String client_version = "clientversion";// 1.1.0

    /**
     * URL构造器 from j2me by zhanglei 4.1
     *
     * @param requestID
     */
    public static String creatUrl(HttpRequestId requestID) {
        StringBuffer request_url = new StringBuffer();
        // 地址
        request_url.append(ServerDomain);
        request_url.append(net_interface[requestID.ordinal()]);
        //request_url.append(protocol_form);

        return request_url.toString();
    }

//	public static String creatPath(int requestID) {
//		StringBuffer request_url = new StringBuffer();
//		// 地址
//		request_url.append(ServerDomain);
//		request_url.append(net_interface[requestID]);
//        request_url.append("?"+dev_id+"="+DeviceID);
//		return request_url.toString();
//	}

    /**
     * 生产请求提交的post数据
     *
     * @param postInfo
     *
     */
//	public static String generatePostString(String[][] postInfo) {
//		if (postInfo == null)
//			return "";
//		StringBuffer postString = new StringBuffer();
//		for (int i = 0; i < postInfo.length; i++) {
//			if (i != 0) {
//				postString.append("&");
//			}
//			postString.append(postInfo[i][0] + "=" + postInfo[i][1]);
//		}
//		return postString.toString();
//	}


    /**
     * 获取订单列表
     *
     * @param Page
     * @return
     */
    public static HashMap<String, String> GetOrderList(int Page) {
        HashMap<String, String> requestMap = new HashMap<String, String>();
        requestMap.put(KEY_PARAM_PAGE, String.valueOf(Page));

        return requestMap;
    }

    /**
     * 获取订单详情
     *
     * @param orderId
     * @return
     */
    public static HashMap<String, String> GetOrderDetail(String orderId) {

        HashMap<String, String> requestMap = new HashMap<String, String>();
        requestMap.put(KEY_PARAM_ORDER_ID, orderId);
        return requestMap;
    }


    /**
     * 创建订单
     *
     * @param PatientName
     * @param Sex
     * @param Age
     * @param PatientPhone
     * @param DentistID
     * @param DentistName
     * @param DentistPhone
     * @return
     */
    public static HashMap<String, String> CreateOrder(String PatientName, String Sex, String Age,
                                                      String PatientPhone, String DentistID, String DentistName,
                                                      String DentistPhone) {
        HashMap<String, String> requestMap = new HashMap<String, String>();
        requestMap.put(KEY_PARAM_PATIENT_NAME, PatientName);
        requestMap.put(KEY_PARAM_PATIENT_SEX, Sex);
        requestMap.put(KEY_PARAM_PATIENT_AGE, Age);
        requestMap.put(KEY_PARAM_PATIENT_PHONE, PatientPhone);
        requestMap.put(KEY_PARAM_DENTIST_ID, DentistID);
        requestMap.put(KEY_PARAM_DENTIST_NAME, DentistName);
        requestMap.put(KEY_PARAM_DENTIST_PHONE, DentistPhone);


        return requestMap;

    }

    public static HashMap<String, String> CreateDesignOrder(String OrderId, String Type, String JigongsuoId,
                                                            String Image, String data) {
        HashMap<String, String> requestMap = new HashMap<String, String>();
        requestMap.put(KEY_PARAM_ORDER_ID, OrderId);
        requestMap.put(KEY_PARAM_DESIGN_TYPE, Type);
        requestMap.put(KEY_PARAM_JIGONGSUO_ID, JigongsuoId);
        requestMap.put(KEY_PARAM_DESIGN_DETAIL, data);
        requestMap.put(KEY_PARAM_DESIGN_IMAGE, Image);


        return requestMap;

    }

    public static HashMap<String, String> GetEquipment(String DeviceID) {
        HashMap<String, String> requestMap = new HashMap<String, String>();
        requestMap.put(KEY_PARAM_DEVICE_ID, DeviceID);
        return requestMap;

    }

    public static final String KEY_PARAM_DEVICE_ID = "DeviceID";// 设备编号
    public static final String KEY_PARAM_PAGE = "Page";// 列表页码

    public static final String KEY_PARAM_ORDER_ID = "OrderID";// 订单编号
    public static final String KEY_PARAM_DESIGN_ID = "design_id";// 订单编号
    public static final String KEY_PARAM_PATIENT_NAME = "PatientName";
    public static final String KEY_PARAM_PATIENT_SEX = "Sex";
    public static final String KEY_PARAM_PATIENT_AGE = "Age";
    public static final String KEY_PARAM_PATIENT_PHONE = "PatientPhone";
    public static final String KEY_PARAM_DENTIST_NAME = "DentistName";
    public static final String KEY_PARAM_DENTIST_PHONE = "DentistPhone";
    public static final String KEY_PARAM_DENTIST_ID = "DentistID";
    public static final String KEY_PARAM_DESIGN_TYPE = "DesignType";
    public static final String KEY_PARAM_DESIGN_DETAIL = "Content";
    public static final String KEY_PARAM_JIGONGSUO_ID = "JigongsuoId";
    public static final String KEY_PARAM_DESIGN_IMAGE = "Image";

}
